{% extends 'TopxiaWebBundle::layout.html.twig' %}

{% set bodyClass = 'course-list-page bg-blank' %}
{% set siteNav = 'course/explore' %}
{% set script_controller = 'course/explore' %}

{% block keywords %}{% if categoryArray %}{{categoryArray.name}}{% if categoryParent %}{{ ','}}{{ categoryParent.name|default('') }}{% endif %}{% else %}{{ '全部' }}{% endif %}{% endblock %}
  {% block description %}{{ categoryArrayDescription|default('')|plain_text(100) }}{% endblock %}
    {% block title %}{{ categoryArray.name|default('全部'|trans) }} - {{setting('site.name')}}{% if setting('site.slogan') %}{{' - '}}{{setting('site.slogan')}}{% endif %}{% if not setting('copyright.owned') %} - Powered By EduSoho{% endif %}
    {% endblock %}

{% block top_content %}
  <div class="es-banner">
    <div class="container">
      <div class="title">
        <i class="es-icon es-icon-viewcomfy"></i>
        {{'课程列表'|trans}}
      </div>

      {% set classrooms = data('Classrooms',{count:1}) %}
      {% if classrooms|default(null) %}
        <a class="btn btn-primary btn-lg more" href="{{path('classroom_explore')}}">
          查看{{ setting('classroom.name')|default('班级') }}
        </a>
      {% endif %}
    </div>
  </div>
{% endblock %}

{% block content %}
  {% set type = filter.type|default('all') %}
  {% set price = filter.price|default('all')%}
  {% set orderBy = orderBy|default('latest')%}
  {% set currentLevelId = filter.currentLevelId|default('all')%}
  {{ render(controller('TopxiaWebBundle:Category:treeNav',{category:category|default(''), path:'course_explore',filter:{type: type,price: price,currentLevelId: currentLevelId},orderBy:orderBy})) }}
  <div class="es-filter">
    <ul class="nav nav-sort clearfix">
      <li><a href="{{ path('course_explore', {category:category, filter: {type: type,price: price,currentLevelId: currentLevelId},orderBy: 'latest'}) }}" class="{% if (orderBy == 'latest') %}active{% endif %}">{{'最新'|trans}}</a></li><li><a href="{{ path('course_explore', {category:category, filter: {type: type,price: price,currentLevelId: currentLevelId},orderBy: 'studentNum'}) }}" class="{% if (orderBy == 'studentNum') %}active{% endif %}">{{'最热'|trans}}</a></li><li><a href="{{ path('course_explore', {category:category, filter: {type: type,price: price,currentLevelId: currentLevelId},orderBy: 'recommendedSeq'}) }}" class="{% if (orderBy == 'recommendedSeq') %}active{% endif %}">{{'推荐'|trans}}</a></li>
    </ul>
    <div class="filter hidden-xs">
      {% if is_plugin_installed('vip')%}
        <div class="btn-group">
          <button type="button" class="btn dropdown-toggle" data-toggle="dropdown" aria-expanded="false"><i class="es-icon es-icon-crown text-warning"></i>
            {% if (currentLevelId == 'all') %}{{'会员课程'|trans}}{% endif %}
            {% for level in levels%}{% if (level.id == currentLevelId) %}{{level.name}}{% endif %}{% endfor %}
          </button>
          <ul class="dropdown-menu" role="menu">
          <li role="presentation"class="{% if (currentLevelId == 'all') %}active {% endif %}"><a href="{{ path('course_explore', {category:category, filter: {type: type,price: price,currentLevelId: 'all'},orderBy: orderBy}) }}">{{'全部'|trans}}</a></li>
          {% for level in levels %}
            <li role="presentation"class="{% if (level.id == currentLevelId) %}active {% endif %}"><a href="{{ path('course_explore', {category:category, filter: {type: type,price: price,currentLevelId: level.id},orderBy: orderBy}) }}">{{level.name}}</a></li>
          {% endfor %}
          </ul>
        </div>
      {% endif %}
      <label class="checkbox-inline">
        <input type="checkbox" {% if type == 'live'%}checked="true" {% endif %} id="live" value="
        {% if type == 'all'%}
          {{ path('course_explore', {category:category, filter: {type: 'live',price: price,currentLevelId: currentLevelId},orderBy: orderBy}) }}
        {% else %}
          {{ path('course_explore', {category:category, filter: {type: 'all',price: price,currentLevelId: currentLevelId},orderBy: orderBy}) }}
        {% endif %}"> {{'直播课程'|trans}}
      </label>
      <label class="checkbox-inline">
        <input type="checkbox" {% if price == 'free'%}checked="true" {% endif %} id="free" value="
        {% if price == 'all'%}
          {{ path('course_explore', {category:category, filter: {type: type,price: 'free',currentLevelId: currentLevelId},orderBy: orderBy}) }}
        {% else %}
          {{ path('course_explore', {category:category, filter: {type: type,price: 'all',currentLevelId: currentLevelId},orderBy: orderBy}) }}
        {% endif %}
        "> {{'免费课程'|trans}}
      </label>
    </div>
  </div>

  <div class="course-list">
    <div class="row">
      {% if courses %}
        {% for course in courses %}
          <div class="col-lg-3 col-md-4 col-xs-6">
            {% include 'TopxiaWebBundle:Course:Widget/course-grid.html.twig' %}
          </div>
        {% endfor %}
      {% else %}
        <div class="empty">{{'该分类下无课程'|trans}}</div>
      {% endif %}
    </div>
  </div>
  <nav class="text-center">
    {{ web_macro.paginator(paginator) }}
  </nav>
{% endblock %}
